﻿* Encoding: UTF-8.

*Always begin by weighting.
WEIGHT BY weight.


*Newsint, ideo5, PID3 and PID7 are raw data from YouGov based on their "profile" items.
compute age=2015-birthyr.
execute.
compute male=gender.
recode male (1=1)(2=0)(else=sysmis).
value labels male '0' "female" '1' "male".
execute.

compute polint=newsint.
recode polint (7=0)(4=1)(3=2)(2=3)(1=4).
VALUE LABELS polint '0' "dk" '1' "hardly at all" '2' "only now & then" '3' "some of the time" '4' "most of the time".
execute.

compute ideostr=ideo5.
recode ideostr (6=0)(3=1)(2=2)(4=2)(1=3)(5=3).
VALUE LABELS ideostr '0' "not sure" '1' "moderate" '2' "lib/con" '3' "strong lib/con".
execute.
MISSING VALUES polint ideostr (8, 9).
execute.


*Below slices the measure of partisanship in difference forms to facilitate the various anayses.

compute pid5=pid7.
execute.
recode pid5 (1=1)(2=1)(3=2)(4=3)(5=4)(6=5)(7=5)(8=3).
execute.
missing values pid5 (98, 99).
value labels pid5 '1' "Dem" '2' "Dem lean" '3' "True Ind" '4' "Rep lean" '5' "Rep".
execute.

compute indep.contin=pid7.
recode indep.contin (4=2)(3=1)(5=1)(2=0)(6=0)(1=0)(7=0)(else=sysmis).
execute.
do if ((pid3=4) or (pid3=5)).
recode indep.contin (2=sysmis)(1=sysmis).
end if.
execute.
VALUE LABELS indep.contin '2' "True independents" '1' "Leaners" '0' "True Partisans".

compute nonpart.contin=pid7.
recode nonpart.contin (4=2)(8=2)(3=1)(5=1)(2=0)(6=0)(1=0)(7=0)(else=sysmis).
execute.
VALUE LABELS nonpart.contin '2' "Independents/Other/Unsure" '1' "Leaners" '0' "True Partisans".


*This simply changes the values of the three categories to make it easier to make inferences from our analysis.
compute leaners.vs=nonpart.contin.
recode leaners.vs (1=1)(0=0)(2=-1).
VALUE LABELS leaners.vs '1' "Leaners" '0' "True Partisans" '-1' "Independents".
execute.

*This simply changes the values of the five categories to make it easier to make inferences from our analysis.
compute pid5.ind=pid5.
recode pid5.ind (3=5)(5=4)(4=3)(2=2)(1=1).
execute.
value labels pid5.ind '1' "Dem" '2' "Dem lean" '3' "Rep Lean" '4' "Rep" '5' "True Independent".
execute.


*Dependent variables.
*num_people, talk_politics are raw data from survey.
*identify_Dem, identify_Rep, identify_other, identify_none are raw data from a single item.

MISSING VALUES num_people talk_politics (-8, -9).
MISSING VALUES identify_dem identify_rep identify_other identify_none (-8, -9).
execute.

compute partisan_sum=identify_dem+identify_rep.
execute.
compute nonpartisan_sum=(identify_other+identify_none).
execute.
compute partisan_imbalance=ABS(identify_dem-identify_rep).
execute.
compute liberal_imbalance=(identify_dem-identify_rep).
execute.


*Frequencies for all variables employed in analysis (ignoring intermediate steps).
FREQUENCIES VARIABLES=age male educ ideostr polint leaners.vs pid5.ind polint talk_politics num_people partisan_sum nonpartisan_sum partisan_imbalance liberal_imbalance
  /STATISTICS=STDDEV MINIMUM MAXIMUM MEAN MEDIAN MODE
  /ORDER=ANALYSIS.


*Formal bivariate test, includes pairwise comparisons across the three levels of the IV.
ONEWAY talk_politics num_people partisan_sum nonpartisan_sum partisan_imbalance  BY leaners.vs
  /ES=OVERALL
  /PLOT MEANS
  /MISSING ANALYSIS
  /CRITERIA=CILEVEL(0.95)
  /POSTHOC=BONFERRONI ALPHA(0.05).


*Next we move to multivariate analysis using with broad partisans IV to allow use of full sample and control spurious "effects" of ideostrength and interest to examine more pure effects of partisanship on networks.
UNIANOVA talk_politics BY leaners.vs WITH age male educ ideostr polint
  /RANDOM=leaners.vs
  /METHOD=SSTYPE(3)
  /INTERCEPT=INCLUDE
  /PLOT=PROFILE(leaners.vs) TYPE=BAR ERRORBAR=CI 
  /EMMEANS=TABLES(leaners.vs) WITH(age=MEAN male=MEAN educ=MEAN ideostr=MEAN polint=MEAN) COMPARE 
    ADJ(BONFERRONI)
  /PRINT ETASQ DESCRIPTIVE PARAMETER
  /CRITERIA=ALPHA(.05)
  /DESIGN=leaners.vs age male educ ideostr polint.
UNIANOVA num_people BY leaners.vs WITH age male educ ideostr polint
  /RANDOM=leaners.vs
  /METHOD=SSTYPE(3)
  /INTERCEPT=INCLUDE
  /PLOT=PROFILE(leaners.vs) TYPE=BAR ERRORBAR=CI 
  /EMMEANS=TABLES(leaners.vs) WITH(age=MEAN male=MEAN educ=MEAN ideostr=MEAN polint=MEAN) COMPARE 
    ADJ(BONFERRONI)
  /PRINT ETASQ DESCRIPTIVE PARAMETER
  /CRITERIA=ALPHA(.05)
  /DESIGN=leaners.vs age male educ ideostr polint.
UNIANOVA partisan_sum BY leaners.vs WITH age male educ ideostr polint
  /RANDOM=leaners.vs
  /METHOD=SSTYPE(3)
  /INTERCEPT=INCLUDE
  /PLOT=PROFILE(leaners.vs) TYPE=BAR ERRORBAR=CI 
  /EMMEANS=TABLES(leaners.vs) WITH(age=MEAN male=MEAN educ=MEAN ideostr=MEAN polint=MEAN) COMPARE 
    ADJ(BONFERRONI)
  /PRINT ETASQ DESCRIPTIVE PARAMETER
  /CRITERIA=ALPHA(.05)
  /DESIGN=leaners.vs age male educ ideostr polint.
UNIANOVA nonpartisan_sum BY leaners.vs WITH age male educ ideostr polint
  /RANDOM=leaners.vs
  /METHOD=SSTYPE(3)
  /INTERCEPT=INCLUDE
  /PLOT=PROFILE(leaners.vs) TYPE=BAR ERRORBAR=CI 
  /EMMEANS=TABLES(leaners.vs) WITH(age=MEAN male=MEAN educ=MEAN ideostr=MEAN polint=MEAN) COMPARE 
    ADJ(BONFERRONI)
  /PRINT ETASQ DESCRIPTIVE PARAMETER
  /CRITERIA=ALPHA(.05)
  /DESIGN=leaners.vs age male educ ideostr polint.
UNIANOVA partisan_imbalance BY leaners.vs WITH age male educ ideostr polint
  /RANDOM=leaners.vs
  /METHOD=SSTYPE(3)
  /INTERCEPT=INCLUDE
  /PLOT=PROFILE(leaners.vs) TYPE=BAR ERRORBAR=CI 
  /EMMEANS=TABLES(leaners.vs) WITH(age=MEAN male=MEAN educ=MEAN ideostr=MEAN polint=MEAN) COMPARE 
    ADJ(BONFERRONI)
  /PRINT ETASQ DESCRIPTIVE PARAMETER
  /CRITERIA=ALPHA(.05)
  /DESIGN=leaners.vs age male educ ideostr polint.

*Distinguishing partisan "sides" of partisans and leaners.
UNIANOVA liberal_imbalance BY pid5.ind WITH age male educ ideostr polint
  /RANDOM=pid5.ind
  /METHOD=SSTYPE(3)
  /INTERCEPT=INCLUDE
  /PLOT=PROFILE(pid5.ind) TYPE=BAR ERRORBAR=CI 
  /EMMEANS=TABLES(pid5.ind) WITH(age=MEAN male=MEAN educ=MEAN ideostr=MEAN polint=MEAN) COMPARE 
    ADJ(BONFERRONI)
  /PRINT ETASQ DESCRIPTIVE PARAMETER
  /CRITERIA=ALPHA(.05)
  /DESIGN=pid5.ind age male educ ideostr polint.

